package com.simtop.picture.utils;

import com.simtop.picture.service.PictureService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class ClearDataJob {

    public Logger logger= LoggerFactory.getLogger(ClearDataJob.class);

    @Autowired
    public PictureService pictureService;

    @Scheduled(cron = "0 43 15 * * ?")
    public void clearDataJob(){
        pictureService.deleteUser();
        logger.info("定时删除用户数据");
    }

    public static void main(String[] args) {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(sdf.format(new Date()));
        long ms=System.currentTimeMillis();
        Date date=new Date(ms-1000*60*60*24*1);
        System.out.println(sdf.format(date));
    }

}
